
<template>
  <view>
    <!-- 基础用法 -->
    <luyj-tree v-slot:default="{item}" @sendValue='toInfo' :is-check='true' @change='seItem' :search-if='false' :max="max" :trees="tree">
        <view>
            <view class="content-item">
                <view class="word">{{item.label}}</view>
            </view>
        </view>
    </luyj-tree>
  </view>
</template>

<script>
	import { treeselect } from "@/api/system/dept";
  export default {
    data() {
      return {
		  itemData:{},
		  tree:[],
		  max: 5,
      }  
    },
	onLoad() {
		this.getTreeselect()   
	},
	methods:{
		seItem(e){
			this.itemData.id = e[0].id
			this.itemData.label = e[0].label
			console.log(e)
		},
		/** 查询组织下拉树结构 */
		getTreeselect() {
		  treeselect().then(response => {
			  console.log(response)
			this.tree = response.data
		  });
		},
		toInfo(){
			let pages = getCurrentPages();
			let prevPage = pages[pages.length - 2];
			prevPage.$vm.deptData = this.itemData;
			uni.navigateBack({
				delta: 1
			});
		}
	}
  }
</script>
